import http from "@/utils/request";

class ServiceAPI {
  // test get api
  static getMessageBoardsList(params = {}) {
    return http.post("/messageBoards/list", params, {
      custom: {
        auth: true,
        loading: true,
      },
    });
  }
  static postMessageBoards(params = {}) {
    return http.post("/messageBoards", params, {
      custom: {
        auth: true,
        loading: true,
      },
    });
  }
  // 获取未读消息
  static getUnreadMessageCount(params = {}) {
    return http.get("/messageBoards/category", {
      params,
      custom: {
        auth: true,
        loading: true,
      },
    });
  }
  // 查询消息详情
  static async getMessageBoardsDetail(id) {
    await this.setMessageBoardsRead(id);
    return http.get(`/messageBoards/query/${id}`);
  }

  // 设置已读状态
  static setMessageBoardsRead(id) {
    return http.put(`/messageBoards`, {
      id,
      status: 3,
    });
  }
}

export default ServiceAPI;
